#include <gui/settingpage_screen/SettingPageView.hpp>

#include <texts/TextKeysAndLanguages.hpp>
#include "BitmapDatabase.hpp"

SettingPageView::SettingPageView()
{

}

void SettingPageView::setupScreen()
{
    SettingPageViewBase::setupScreen();
}

void SettingPageView::tearDownScreen()
{
    SettingPageViewBase::tearDownScreen();
}
//页面跳转
void SettingPageView::SettingPageChange(uint8_t newFiveKeyFunc)
{
		handleKeyEvent(newFiveKeyFunc);
}
//背光亮度滑动条
void SettingPageView::updateBacklightText(int value)
{
    Unicode::snprintf(textBackLightValBuffer, TEXTBACKLIGHTVAL_SIZE, "%d", value);
    textBackLightVal.resizeToCurrentText();
    container.invalidate();
}
//slider控件值改变
void SettingPageView::newBacklightValueHandler(int value)
{
    //presenter->setBacklightValue(value);
    updateBacklightText(value);
}
//排水操作
void SettingPageView::drainWater()
{
		bool enable = tButtonWater.getState();
		//
		presenter->drainWaterStatus(enable);	//排水使能
}
//tick事件
void SettingPageView::handleTickEvent()
{
	static int timCnt = 0;
	//排水按钮点击
	if(tButtonWater.getState() == true) 
	{
			timCnt++;	
	}
	else 
	{
			timCnt = 0;
	}
	//计时时间
	if(timCnt >= 200)
	{
		tButtonWater.forceState(false);
		tButtonWater.setBitmaps(touchgfx::Bitmap(BITMAP_WATER_OFF_50X50_ID),touchgfx::Bitmap(BITMAP_WATER_ON_50X50_ID));	
		tButtonWater.invalidate();
		//
		presenter->drainWaterStatus(false);	//排水完成
		//计数清零
		timCnt = 0;
	}
}